﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<link href="js-console.css" rel="stylesheet" />
	<!-- 2. Write a function that reverses the digits of given 
			decimal number. Example: 256 -> 652  -->
</head>
<body>
	<div id="js-console"></div>
	<script src="js-console.js"></script>
	<script>
		function reverseNumber(number) {
			var strNumber = number.toString();
			var result = "";

			for (var i = strNumber.length - 1; i >= 0; i--) {
				result += strNumber[i];
			}

			return result;
		}

		var number = parseInt(prompt("Enter number"));

		if (!isNaN(number)) {
			jsConsole.writeLine("The number with reversed digits is: " + reverseNumber(number));
		}
		else {
			jsConsole.writeLine("Wrong input.");
		}
	</script>
</body>
</html>
